home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d3
/
db4less3.arc
/
TRANPROC.PRG
< prev
next >
Wrap
Text File
|
1990-06-16
|
1KB
|
50 lines
* TRANPROC.PRG
* Example of Transaction Processing
*
* Also: Procedure, On Error, LKSYS(), Set Reprocess
SET REPROCESS TO 10 && Try network locks 10 times before error
ON ERROR DO errproc && Procedure errproc handles ROLLBACK
fileok=.T.
USE emp
IF fileok
BEGIN TRANSACTION && Begin transaction logging
REPLACE ALL lname WITH 'BRUCE' FOR lname = 'Bruce' && ERROR IF LOCKED
LIST LNAME
WAIT
END TRANSACTION && End transaction logging and update
LIST LNAME
ENDIF
ON ERROR && Reset error handling
RETURN
PROCEDURE ERRPROC
MANS='N'
CLEAR
DO CASE
CASE ERROR() = 108 && File locked
otheruser=IIF(LEN(LKSYS(2))=0,'another',LKSYS(2)) && if no user name
WAIT 'File is locked by '+TRIM(otheruser)+'. Press any key.'
fileok=.F.
RETURN
CASE ERROR() = 109 && Record locked
otheruser=IIF(LEN(LKSYS(2))=0,'another',LKSYS(2)) && if no user name
WAIT 'Record is locked by '+TRIM(otheruser)+'. Press any key.'
OTHERWISE && Any other error
@ 1,0 SAY MESSAGE()+' '+STR(ERROR(),4)
ENDCASE
@ 2,0 SAY 'DO YOU WISH TO RETRY? ' GET MANS FUNCTION '!'
READ
IF MANS='Y' && Retry
CLEAR
RETRY
ELSE && Rollback
CLEAR
@ 0,0 SAY 'ROLLING BACK YOUR CURRENT TRANSACTIONS...'
ROLLBACK
ENDIF
RETURN
* EOP: TRANPROC.PRG